package src.view;

import src.event.EventListener;
import src.event.events.SelectionUpdateEvent;

/**
 * <b>Overview</b>
 * The SelectionCacheHandler updates the MapDataCache based on events it receives from the model.
 *
 * <b>Responsibilities</b>
 * Manipulate the MapDataCache appropriately when incoming changes occur.
 *
 * <b>Collaborators</b>
 * MapDataCache - Subcontractor: The MapDataCahce must be told how to update when each event is received.
 * SelectionUpdateEvent - Client: SelectionUpdateEvents notify the SelectionCacheHandler of what to change and when to change it.
 *
 * <b>Implementor</b> - Bruce
 * <b>Tester</b> - Tim
 *
 * @author Bruce
 */
public class SelectionCacheHandler implements EventListener<SelectionUpdateEvent>
{
	private MapDataCache cache;

	public SelectionCacheHandler(MapDataCache cache)
	{
		this.cache = cache;
	}

	/* (non-Javadoc)
	 * @see src.event.EventListener#eventCallback(src.event.Event)
	 */
	public boolean eventCallback(SelectionUpdateEvent e)
	{
		cache.select(e.getSelection());
		return true;
	}
}